1. Field of the Invention
This invention relates to resident computer memory, and particularly to system methods and computer products for reclaiming resident buffers on demand.
2. Description of Background
Resident computer memory is often used to pass data between a Network Interface Card (NIC) and a computer. Typically, an inbound or outbound packet is immediately copied from resident memory to more plentiful nonresident buffers, so the limited resident memory can be reused for subsequent packets. Copying data is extremely expensive, and can cost as much as 50% of the total network CPU consumption. An alternative is to pin and unpin memory, converting it from resident to nonresident memory, but this is also very expensive and may require an additional step to remap memory so it is accessible by the NIC DMA engine. A third alternative is to eliminate the buffer copy by allowing the TCP/IP stack to process the data directly in the resident buffers without copying or unpinning the memory. This approach sounds good; however, the TCP/IP stack protocol consumes considerable buffer resources and often queues buffers for indeterminate periods of time to accommodate inbound and outbound flow control (e.g., TCP window). A mechanism is required to reclaim in-use resident buffer resources from the TCP/IP stack.
A multi-layered network protocol such as TCP/IP inserts and removes protocol headers as packets are passed up and down the network protocol layers. Each protocol layer has a different view of the data; for example, the socket layer processes a raw buffer (multiple packets) containing no protocol headers, TCP inserts/removes TCP headers, IP inserts/removes IP headers and the LAN network driver inserts/removes link headers. A simplistic approach is to just copy and reformat the data at each protocol layer; however, this is obviously very expensive, so buffer management mechanisms have been defined that use reference counts and message structures to allow a single buffer to be shared, adjusting pointers to remove and add headers. For example Linux uses sk_buffs and other systems such as System i5, AIX, HP and Sun use STREAMS. Since, STREAMS is the most widely used buffer management protocol it is chosen as the preferred embodiment for this invention.
In a buffer expiration method, all resident buffers are marked with a “critical” bit and each protocol layer is responsible to start a timer every time a critical buffer is queued. When a timer expires, the critical buffer is reclaimed (i.e., data copied and critical buffer is freed). Since, the TCP protocol uses a retransmit timer for its queued send buffers, it is reasonable to also use this same timer as a buffer expiration timer. However, the TCP/IP protocol doesn't maintain any timers for its queued receive buffers. Receive buffers may be queued in multiple places: IP reassembly queue, out-of-order segment queue and socket receive queue. Unfortunately, no timer is implemented for receive buffers; therefore, addition timers are required to support the buffer expiration method. The main problems with the buffer expiration method include: timers being expensive; reclaim is triggered by a timer and not by a real buffer shortage, causing: buffers to be reclaimed too soon (i.e., timer expires, but there is no buffer shortage) and buffers to be reclaimed too late (i.e., buffer shortage occurs and timers don't expire).
In a search and reclaim method, all resident buffer are marked with a “critical” bit and a buffer shortage is detected by the buffer pool manager and the TCP/IP stack is notified. In general, the TCP/IP stack performs a linear search through all of it connection endpoints and reclaims critical buffers. The search and reclaim method is triggered by a buffer shortage instead of a timer to ensure that buffers are only reclaimed when needed. This is an on demand approach: however, the processing required to find and reclaim buffers is extremely CPU intensive. Therefore, the search and reclaim must be initiated infrequently and large numbers of buffers must be reclaimed during each cycle to reduce the number of search and reclaim cycles. This method causes large CPU spikes and reclaims more buffers than are really necessary. An ideal method must spread the reclaim processing more evenly to prevent CPU spikes.
In a hot swap method, a severe buffer shortage is detected by the buffer pool manager and the current resident buffers are unpinned and unmapped. In general, new buffers are allocated, pinned and mapped to replenish the buffer pool. The hot swap method is a novel approach; however, like the search and reclaim method, it causes large CPU spikes and is extremely CPU intensive. The hot swap should only be used when the other reclaim methods are not effective and the buffer shortage becomes so severe that immediate action is required to replenish the buffer pool.